
/*
 * redmicro all Copyright (c)
 */

Rsd.define('Rsd.Faith.pages.BookDanYuanMingXiZhangPage', {
    extend: 'Rsd.container.Page',
    requires: [
        'Rsd.Faith.stores.ListStore',
        'Rsd.Faith.controls.XiaoQuListView',
        'Rsd.control.GridToolBar',
        'Rsd.control.PagingBar'],
    xtype: 'list-f-dan-yuan',
    border: false,
    tabTitle: '小区楼栋',
    layout:'border',
    items:[
        {
            region: 'west',
            xtype:'list-xiaoqu',
            border:true,
            itemClick:'item_click',
            margin: '0 10 0 0',
            width:300
        },
        {
            xtype:'grid',
            region: 'center',
            pageIndexChanged:'pageIndexChanged',
            label:{
                xtype: 'grid-tool-bar',
                height:60,width:'100%',
                searchColumns:[{name:'LouDongHao',text:'楼栋号'},{name:'DanYuanHao',text:'单元'}],
                searchHandler:'loadZhangMuRows'
            },
            //footBar:{xtype:'paging-bar',indexChanged:'pageIndexChanged'},
            columns:[
                {
                    "text": "序号",
                    "xtype": "index",
                    "width": 40,
                    "index": 0,
                    "deep": 1
                },

                {
                    "name": "LouDongHao",
                    "dataIndex": "LouDongHao",
                    "sortable": false,
                    "text": "楼栋号",
                    "index": 23,
                    "exist": true,
                    "xtype": "string",
                    align:'center',
                    "width": 50,
                    "nobr": true,
                    "deep": 1
                },
                {
                    "name": "DanYuanHao",
                    "dataIndex": "DanYuanHao",
                    "sortable": false,
                    "text": "单元",
                    "index": 23,
                    "exist": true,
                    "xtype": "string",
                    align:'center',
                    "width": 50,
                    "nobr": true,
                    "deep": 1
                },
                {
                    "name": "SuoShuQi",
                    "dataIndex": "SuoShuQi",
                    "sortable": false,
                    "text": "当前所属期",
                    "index": 24,
                    "exist": true,
                    "xtype": "string",
                    align:'center',
                    "width": 50,
                    "nobr": true,
                    "deep": 1
                },

                {
                    "name": "JiaoCunJinE_ZZ",
                    "dataIndex": "JiaoCunJinE_ZZ",
                    "sortable": false,
                    "text": "缴存(住房)",
                    "index": 28,
                    "exist": true,
                    "xtype": "number",
                    "total":true,
                    "width": 100,
                    "precision": 2,
                    "deep": 1
                },

                {
                    "name": "ShiYongJinE_ZZ",
                    "dataIndex": "ShiYongJinE_ZZ",
                    "sortable": false,
                    "text": "使用(住房)",
                    "index": 32,
                    "exist": true,
                    "xtype": "number",
                    "total":true,
                    "width": 100,
                    "precision": 2,
                    "deep": 1
                },
                {
                    "name": "YuE_ZZ",
                    "dataIndex": "YuE_ZZ",
                    "sortable": false,
                    "text": "余额(住房)",
                    "index": 40,
                    "exist": true,
                    "xtype": "number",
                    "total":true,
                    "width": 100,
                    "precision": 2,
                    "deep": 1
                },
                {
                    "name": "ShouYiJinE_ZZ",
                    "dataIndex": "ShouYiJinE_ZZ",
                    "sortable": false,
                    "text": "统筹余额",
                    "index": 30,
                    "exist": true,
                    "xtype": "number",
                    "total":true,
                    "width": 100,
                    "precision": 2,
                    "deep": 1
                },
                {
                    "name": "FenHuLiXi",
                    "dataIndex": "FenHuLiXi",
                    "sortable": false,
                    "text": "分户利息合计",
                    "index": 30,
                    "exist": true,
                    "xtype": "number",
                    "total":true,
                    "width": 100,
                    "precision": 2,
                    "deep": 1
                },
                /*
                {
                    "name": "JiaoCunJinE_DT",
                    "dataIndex": "JiaoCunJinE_DT",
                    "sortable": false,
                    "text": "缴存(电梯/消防)",
                    "index": 34,
                    "exist": true,
                    "xtype": "number",
                    "width": 100,
                    "precision": 2,
                    "deep": 1
                },
                {
                    "name": "ShouYiJinE_DT",
                    "dataIndex": "ShouYiJinE_DT",
                    "sortable": false,
                    "text": "增值(电梯/消防)",
                    "index": 36,
                    "exist": true,
                    "xtype": "number",
                    "width": 100,
                    "precision": 2,
                    "deep": 1
                },
                {
                    "name": "ShiYongJinE_DT",
                    "dataIndex": "ShiYongJinE_DT",
                    "sortable": false,
                    "text": "使用(电梯/消防)",
                    "index": 38,
                    "exist": true,
                    "xtype": "number",
                    "width": 100,
                    "precision": 2,
                    "deep": 1
                },

                {
                    "name": "YuE_DT",
                    "dataIndex": "YuE_DT",
                    "sortable": false,
                    "text": "余额(电梯/消防)",
                    "index": 42,
                    "exist": true,
                    "xtype": "number",
                    "width": 100,
                    "precision": 3,
                    "deep": 1
                },*/
                {
                    "name": "ZhangHuBianHao",
                    "dataIndex": "ZhangHuBianHao",
                    "sortable": false,
                    "text": "账户编号",
                    "index": 20,
                    "exist": true,
                    "xtype": "string",
                    "width": 120,
                    "nobr": true
                },
                {
                    "name": "JianZhangRiQi",
                    "dataIndex": "JianZhangRiQi",
                    "sortable": false,
                    "text": "建账日期",
                    "index": 24,
                    "exist": true,
                    "xtype": "date",
                    "formatString": "yyyy-MM-dd",
                    "width": 100,
                    "precision": 3
                },
                {
                    "name": "ZhuangTai",
                    "dataIndex": "ZhuangTai",
                    "sortable": false,
                    "text": "状态",
                    "index": 44,
                    "exist": true,
                    "xtype": "enum",
                    "enum": {
                        "name": "Rsd.Faith.Core.ZhuangHuZhuangTai",
                        "items": [
                            {
                                "code": "DG",
                                "text": "中心代管",
                                "value": 0
                            },
                            {
                                "code": "ZG",
                                "text": "小区自管",
                                "value": 1
                            },
                            {
                                "code": "TH",
                                "text": "已退伙",
                                "value": 2
                            }
                        ]
                    },
                    "width": 100,
                    "nobr": true,
                    "deep": 1
                },
                {
                    "name": "Remark",
                    "dataIndex": "Remark",
                    "sortable": false,
                    "text": "备注",
                    "index": 50,
                    "exist": true,
                    "xtype": "string",
                    "width": 50,
                    "nobr": true,
                    "deep": 1
                }
            ]

        }
    ],
    formFields: [

    ],
    /*
    * */
    constructor: function (config) {
        config = config || {};
        Rsd.apply(this, config);


        var _grid = this.items[1];
        _grid.dataSource = Rsd.widget('listStore');
    },
    load:function () {
        var me = this;
        setTimeout(function () {
            me.items[0].loadData();
        },50);
    },
    item_click:function(item)
    {
        var me = this;
        me.__xiao_qu_bian_hao = item.content.key;
        me.loadZhangMuRows();
    },


    /*
     * */
    loadZhangMuRows:function loadLouDongRows( args) {

        var me = this;
        var  bian_hao= me.__xiao_qu_bian_hao;
        if(Rsd.isEmpty(bian_hao))
        {
            Rsd.alert("请选择小区");
            return;
        }
        var where = [{name:'xiaoqubianhao',value:bian_hao,op:'equals'}];
        var _args = args||[];
        for(var i in _args)
        {
            where.push(_args[i]);
        }
        var grid = me.items[1];
        Rsd.showWaiting(this.id,grid);
        grid.loadData({
                modelType: 'Rsd.Faith.Models.BookDanYuanMingXiZhangModel',
                where:where,
                sort:[{name:'SuoShuQi',direction:'asc'},{name:'LouDongHao',direction:'asc'}]
            },
            function(data ){

                Rsd.closeWaiting(me.id);
            });

    }


});


